/**
 * 
 */
package com.xpec.c4.service.group.transportlayer;

import java.util.TimerTask;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.xpec.c4.service.common.MessageHandle;

/**
 * 
 * 
 * @author lipeilin
 * @2011-3-18 下午02:24:07
 * 
 */
public class MessageTask extends TimerTask {

	private static final Log log = LogFactory.getLog(MessageTask.class);

	private GroupMessage message;

	public MessageTask(GroupMessage msg) {
		message = msg;
	}

	@Override
	public void run() {
		// log.info(content);
		int messageType = 0;
		try {
			messageType = message.getMessageType();
			MessageHandle.handleMessage(messageType,
					message.getSyncId(),
					message.getMessageContentBytes(),
					message.getSessionID(),
					message.getDestModuleID(),
					message.getSrcService(),
					null);
		} catch (Exception e) {
			log.error(
					"handle message error!sessionID:" + message.getSessionID()
							+ " moduleID:" + message.getDestModuleID()
							+ " messageType:" + messageType, e);
		}

	}

	@Override
	public String toString() {
		return String.valueOf(message);
	}

}
